<?php
/**
 * @author shutyuka@gmail.com
 * @modified 2011-02-20
 */
class SalaryMonth{
	
	static public $FLAG_INACTIVE = 0;
	
	static public $STATUS_UNACTIVE = 10;
	
	static public $TABLE_NAME="salary_month";

	static public function Create($salaryMonth) {
//		$salaryMonth = array();
		
//		$salaryMonth['staff_id'] = $staffId;
//		$salaryMonth['shop_id'] = $shopId;
//		$salaryMonth['start_time'] = $startTime;
//		$salaryMonth['end_time'] = $endTime;
//		$salaryMonth['work_total_hour'] = $workTotalHour;
//		$salaryMonth['work_total_minute'] = $workTotalMinute;
//		$salaryMonth['reword_money'] = $rewordMoney;
//		$salaryMonth['bus_money'] = $busMoney;
//		
//		
//		$salaryMonth['change_money'] = $changeMoney;
//		$salaryMonth['other_money'] = $otherMoney;
//		$salaryMonth['batu_money'] = $batuMoney;
//		$salaryMonth['total_money'] = $totalMoney;
		
		
		$salaryMonth['create_time'] = time();
		$salaryMonth['id'] = DB::Insert(self::$TABLE_NAME, $salaryMonth);
		
		return $salaryMonth['id'];
	}
	
	/*static public function Update($staffId, $year, $month, $workTotalHour, $workTotalMinute, 
	$rewordMoney, $busMoney, $changeMoney, $otherMoney, $batuMoney, $totalMoney) {
		$salaryMonth = array();
		
		$salaryMonth['staff_id'] = $staffId;
		$salaryMonth['year'] = $year;
		$salaryMonth['month'] = $month;
		$salaryMonth['work_total_hour'] = $workTotalHour;
		$salaryMonth['work_total_minute'] = $workTotalMinute;
		$salaryMonth['reword_money'] = $rewordMoney;
		$salaryMonth['bus_money'] = $busMoney;
		
		$salaryMonth['change_money'] = $changeMoney;
		$salaryMonth['other_money'] = $otherMoney;
		$salaryMonth['batu_money'] = $batuMoney;
		$salaryMonth['total_money'] = $totalMoney;
		
		
		$salaryMonth['create_time'] = time();
		$salaryMonth['id'] = DB::Insert(self::$TABLE_NAME, $salaryMonth);
		
		return $salaryMonth['id'];
	}*/
	
	static public function Update($service) {
		Table::UpdateCache(self::$TABLE_NAME, $service['id'], $service);
		
		return ;
	}
	
	static public function GetAll(){
		$allShops = DB::LimitQuery(self::$TABLE_NAME, array(
				'order' => 'ORDER BY id ASC'
				));
		return $allShops;
	}
	
	
	static public function GetById($id) {
		if (!$id) return array();
		return DB::GetTableRow(self::$TABLE_NAME, array('id' => $id));
	}
	
	static public function GetByYearMonth($shopId, $startTime, $endTime) {
		$oc = array( 
			"shop_id" => $shopId, "start_time > $startTime", "end_time < $endTime"
			);
		$list = DB::LimitQuery(self::$TABLE_NAME, array(
				'condition' => $oc,
				'order' => 'ORDER BY start_time ASC'
				));
		return $list;
	}
	
	static public function GetByStaffId($staffId) {
		$oc = array( 
			"staff_id" => $staffId
			);
		$list = DB::LimitQuery(self::$TABLE_NAME, array(
				'condition' => $oc,
				'order' => 'ORDER BY start_time ASC'
				));
		return $list;
	}
	
	static public function DeleteById($id, $opId){
				
		$sql = "delete from ".self::$TABLE_NAME." where id=$id" ;
		return DB::GetQueryResult($sql, false);
	}

	
}
